#include <iostream>
#include <opencv2/opencv.hpp>
#include <filesystem>

using namespace cv;
using namespace std;

int main() {

    std::filesystem::path current_path = std::filesystem::current_path();
    std::cout << "Current Path: " << current_path << std::endl;
    std::string path_str = current_path.string();

    // 移除多余字符串
    std::string target_str = "cmake-build-debug";
    size_t found_pos = path_str.find(target_str);
    if (found_pos != std::string::npos) {
        std::cout << "Found '" << target_str << "' in Current Path." << std::endl;
        // 移除找到的字符串
        path_str.erase(found_pos, target_str.length());
    } else {
        std::cout << "Current Path does not contain '" << target_str << "'." << std::endl;
    }

//    Mat img = imread("/Users/HOX4SGH/Downloads/人是怎么破圈开始的.jpeg");
    Mat img = imread(path_str + "/img.png");
    if (img.empty()) {
        cout << "error" << endl;
        return -1;
    }

    imshow("OpenCV", img);
    waitKey(0);
    return 0;
}
